package com.annhoa.interfaces.facade;


import com.annhoa.domain.entity.BlogBar;
import com.annhoa.domain.entity.BlogBarnner;
import com.annhoa.domain.entity.BlogOwers;
import com.annhoa.domain.entity.BlogNewBox;
import com.annhoa.domain.entity.BlogTopPic;
import com.annhoa.domain.repository.BlogBarJpaRepository;
import com.annhoa.domain.repository.BlogBarnnerJpaRepository;
import com.annhoa.domain.repository.BlogOwersJpaRepository;
import com.annhoa.domain.repository.BlogNewBoxJpaRepository;
import com.annhoa.domain.repository.BlogToppicJpaRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * 
 * @author annhoa @date2019-11-13
 *
 */
@RestController
@RequestMapping("/annhoa-blog")
public class BlogController extends BaseController {
	@Autowired
	private BlogBarnnerJpaRepository blogBarnnerJpaRepository;
	@Autowired
	private BlogBarJpaRepository blogBarJpaRepository;
	@Autowired
	private BlogToppicJpaRepository blogToppicJpaRepository;
	@Autowired
	private BlogNewBoxJpaRepository blogNewBoxJpaRepository;
	@Autowired
	private BlogOwersJpaRepository blogOwersJpaRepository;
	
	@GetMapping(value = "/barnnerlist")
	public List<BlogBarnner> listBlogBarnner() {
		List<BlogBarnner> list = blogBarnnerJpaRepository.findAll();
		return list;
	}
	

	@GetMapping(value = "/barlist")
	public List<BlogBar> listBlogBar() {
		return blogBarJpaRepository.findAll();
	}
	
	@GetMapping(value = "/toppiclist")
	public List<BlogTopPic> listToppic() {
		return blogToppicJpaRepository.findAll();
	}
	@GetMapping(value = "/newboxclist")
	public List<BlogNewBox> listnewbox() {
		return blogNewBoxJpaRepository.findAll();
	}
	@GetMapping(value = "/blogOwerslist")
	public Optional<BlogOwers> listblogOwers() {
		return blogOwersJpaRepository.findById((long) 1);
	}
}
